//
//  OYMacro.h
//  qpyd
//
//  Created by 掌游网络 on 2017/7/14.
//  Copyright © 2017年 掌游网络. All rights reserved.
//

#ifndef OYMacro_h
#define OYMacro_h

#pragma mark - 颜色相关
/*************************** ======== 颜色相关 ======== ***************************/
#define OYColorRGBA(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:a]
#define OYColorRGB(r, g, b) OYColorRGBA((r), (g), (b), 1.0)
#define OYRandomColor OYColorRGB(arc4random_uniform(255), arc4random_uniform(255), arc4random_uniform(255))
#define OYGrayColor(a) OYColorRGB((a), (a), (a))
// rgb颜色转换（16进制->10进制）
#define OYRGBFrom16(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
// argb颜色转换 (16进制->10进制)
#define OYARGBFrom16(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:((float)((rgbValue & 0xFF000000) >> 24))/255.0]

#pragma mark - 视图相关
/*************************** ======== 视图相关 ======== ***************************/
//设置圆角
#define OYViewRadius(View, Radius) \
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES];
//设置圆角边框
#define OYViewBorderRadius(View, Radius, Width, Color)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES];\
[View.layer setBorderWidth:(Width)];\
[View.layer setBorderColor:[Color CGColor]];
//由角度转换弧度 由弧度转换角度
#define OYDegreesToRadian(x) (M_PI * (x) / 180.0)
#define OYRadianToDegrees(radian) ((radian) * 180.0) / (M_PI)
//获取图片
#define OYImageNamed(imageName) [UIImage imageNamed:(imageName)]

#pragma mark - 尺寸相关
/*************************** ======== 尺寸相关 ======== ***************************/
//屏幕尺寸
#define OYScreenW CGRectGetWidth([UIScreen mainScreen].bounds)
#define OYScreenH CGRectGetHeight([UIScreen mainScreen].bounds)
// 判断是否为 iPhone 5/5s/SE屏幕
#define iPhone5_5s_SE ([[UIScreen mainScreen] bounds].size.width == 320.0f && [[UIScreen mainScreen] bounds].size.height == 568.0f)
// 判断是否为iPhone 6/6s/7屏幕
#define iPhone6_6s_7 ([[UIScreen mainScreen] bounds].size.width == 375.0f && [[UIScreen mainScreen] bounds].size.height == 667.0f)
// 判断是否为iPhone 6Plus/6sPlus/7Plus屏幕
#define iPhone6Plus_6sPlus_7Plus ([[UIScreen mainScreen] bounds].size.width == 414.0f && [[UIScreen mainScreen] bounds].size.height == 736.0f)
// 判断是否为iPhone X屏幕
#define iPhoneX ([[UIScreen mainScreen] bounds].size.width == 375.0f && [[UIScreen mainScreen] bounds].size.height == 812.0f)
// 判断导航栏高度
#define OYAppNavBarH (OYScreenH == 812.f ? 88.f : 64.f)
#define OYAppTabBarH (OYScreenH == 812.f ? 83.f : 49.f)
// iPhone X 底部安全间距 34
#define OYiPhoneXBottomSafeMargin 34.f

#pragma mark - 系统相关
/*************************** ======== 系统相关 ======== ***************************/
//获取系统对象
#define OYApplication [UIApplication sharedApplication]
#define OYAppWindow [UIApplication sharedApplication].keyWindow
#define OYRootViewController [UIApplication sharedApplication].delegate.window.rootViewController
#define OYUserDefaults [NSUserDefaults standardUserDefaults]
#define OYNotificationCenter [NSNotificationCenter defaultCenter]
//app版本号
#define OYAppVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
//判断系统版本
#define iOS(version) ([[[UIDevice currentDevice] systemVersion] floatValue] >= (version))
//判断是否为iPhone
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
//判断是否为iPad
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
//日志输出
#ifdef DEBUG
#define OYLog(format, ...) printf("[%s] %s [第%d行] %s\n", __TIME__, __FUNCTION__, __LINE__, [[NSString stringWithFormat:format, ## __VA_ARGS__] UTF8String]);
#else
#define OYLog(format, ...)
#endif
#define OYLogFun OYLog(@"")

#pragma mark - 文件相关
/*************************** ======== 文件相关 ======== ***************************/
//获取temp
#define OYPathTemp NSTemporaryDirectory()
//获取沙盒 Document
#define OYPathDocument [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
//获取沙盒 Cache
#define OYPathCache [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]

#pragma mark - 工具类
/*************************** ======== 工具类 ======== ***************************/
//__weak self & __strong self  配对使用
#define OYWeakSelf __weak typeof(self) weakSelf = self;
#define OYStrongSelf __strong typeof(self) self = weakSelf;
//拼接字符串
#define OYNSStringFormat(format, ...) [NSString stringWithFormat:format, ##__VA_ARGS__]















#endif /* OYMacro_h */
